require([
    'jquery',
    'jquery.debounce',
    'jquery.query-object',
    'module/search',
    'requirejs/domready!'], 
function($) {

	var resizeHandler = function(){
		$('.category-nav').css('width', $('body > .container').width());
	};
	
	// window resize handler
	$(window).resize($.debounce( 500, resizeHandler));
	
	$('.category-nav').on('click', '.nav a', function(){
		var code = $(this).data('code');
		window.location.search = jQuery.query.set("category", code);
		return false;
	});
	
	$('#model-tree-toggle').on('click', function(){
		$('body > .container').toggleClass('mmc');
		$(window).trigger('resize');
	});
	
	$('#product-search-form input[name="category"]').val(
			$('.category-nav .nav-tabs > li.active > a').data('code'));
	
	resizeHandler();
});